IRONSOFTWAREHOME
Rasterize a PDF to Images
from ironpdf import *

pdf = PdfDocument.FromFile("my-content.pdf")

# Extract all pages to a folder as image files
pdf.RasterizeToImageFiles(r"C:\image\folder\*.png")

# Dimensions and page ranges may be specified
pdf.RasterizeToImageFiles(r"C:\image\folder\example_pdf_image_*.jpg", 100, 80)

# Extract all pages as AnyBitmap objects
pdfBitmaps = pdf.ToBitmap()
pip install ironpdf
Rasterize a PDF to Images

Rasterize a PDF to Images

IronPDF for Python can rasterize PDF pages into image files or in-memory bitmap objects - useful for generating thumbnails, previews, or image-based exports.

Getting Started

Load a PdfDocument from a file using PdfDocument.FromFile, then call one of the rasterization methods to convert its pages to images.

Understanding the Code

  • RasterizeToImageFiles(pattern): Exports all pages as image files to the specified folder. The filename pattern supports a wildcard (*) that is replaced with the page index. Common formats such as .png and .jpg are supported based on the file extension used in the pattern.
  • RasterizeToImageFiles(pattern, width, height): The optional width and height parameters (in pixels) set the output image dimensions, letting you control the resolution of the exported images.
  • ToBitmap(): Converts all PDF pages to a list of in-memory AnyBitmap objects. These can be processed further in Python without writing to disk.

Choosing an Output Format

  • Use .png in the path pattern for lossless images suitable for document archiving or OCR preprocessing.
  • Use .jpg for smaller file sizes when image quality is less critical, such as web thumbnails.

Page Ranges

To rasterize only specific pages, use RasterizeToImageFiles with an explicit page range overload rather than processing the full document, reducing memory usage for large PDFs.

Learn how to convert PDFs to images with IronPDF for Python!

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required